Selected Row Handling

Add Copy Record Button

Description
This customization allows adding a Copy Button to a Show Table Records page and handle the processing for the selected row on the table.
Variables
Table Control Class
Select a table control
Copy Button
Select the copy button
Table Name
Select the database table.
Applies to
TableControl class
Code
 
''' 
''' Override the ${Copy Button}_Click and get selected records
''' and create new database records.
''' 
Public Overrides Sub ${Copy Button}_Click(ByVal sender As Object, ByVal args As EventArgs)
    Try    
        DbUtils.StartTransaction()
        Dim selectedRecords As ${Table Name}TableControlRow() = Me.GetSelectedRecordControls()
        If (selectedRecords.Length > 0) Then    
            Dim ${Table Name}Rec As ${Table Name}TableControlRow
            For Each ${Table Name}Rec In selectedRecords
                Dim newRec As New ${${Table Name}RecordClassName}
                newRec = CType(${Table Name}Rec.GetRecord.CopyRecord(), ${${Table Name}RecordClassName})
                newRec.Save()
            Next
            DbUtils.CommitTransaction()
        End If
    Catch ex As Exception
        DbUtils.RollBackTransaction()

        'Report the error message to the user
        Utils.MiscUtils.RegisterJScriptAlert(Me, "UNIQUE_SCRIPTKEY", ex.Message)
    Finally
        DbUtils.EndTransaction()
    End Try
End Sub


 

Terms of Service Privacy Statement